﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Saper
{
    public enum Difficulty { NEWBIE, AMATOR, PROFI, SPECIAL };
    
    
    public partial class Form1 : Form
    {

        internal static Timer timer1 = new Timer();
        internal static Label label2 = new Label();
        public SaperGame saper;
        public static int time = 0;
        public static int mineleft;
        private int locationX = 10;
        private int locationY = 50;
        public static Difficulty difficulty;
        
        
                
        public Form1()
        {
            InitializeComponent();
        }

        public void ChangeOptions(int w, int h, int mines, Difficulty dif)
        {
            saper.Dispose();
            saper = new SaperGame(w, h, mines);
            difficulty = dif;
            saper.Parent = this;
            saper.Location = new Point(locationX, locationY + menuStrip1.Height);
            Width = saper.Location.X * 2 + 20 * w + 6;
            Height = saper.Location.Y + 20 * h + 46;
            timer1.Stop();
            timer1.Start();
            time = 0;
            label1.Text = "Время: 0";
            label1.Location = new Point(Width / 2 - label1.Width / 2 - 5, menuStrip1.Height + 13);
            label2.Location = new Point(Width / 2 - label2.Width / 2, menuStrip1.Height + 30);


        }


        private void настройкиToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Options options = new Options(this); 
            options.Show();           
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            int cellHeight = 8;
            int cellWidth = 8;
            mineleft = 10;

            saper = new SaperGame(cellWidth, cellHeight, mineleft);
            saper.Parent = this;
            saper.Location = new Point(locationX, locationY+menuStrip1.Height);
            Width = saper.Location.X * 2 + 20 * cellWidth + 6 ;
            Height = saper.Location.Y + 20 * cellHeight + 46;
            timer1.Enabled = true;
            timer1.Start();
            label1.Location = new Point(Width /2 - label1.Width / 2-5, menuStrip1.Height + 13);
           
            timer1.Interval = 1000;
            timer1.Tick += new System.EventHandler(this.timer1_Tick);

            label2.AutoSize = true;
            label2.Parent = this;
            label2.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(204)));
            label2.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0);
            label2.Name = "label2";
            label2.Size = new System.Drawing.Size(100, 13);
            label2.TabIndex = 2;
            label2.Text = "Осталось мин:10";
            label2.Location = new Point(Width / 2 - label2.Width / 2, menuStrip1.Height + 30);
            




            
        }

 

        private void таблицаРекордовToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Scores scores = new Scores();
            scores.Show();
        }

        private void выходToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Close();
        }

        private void timer1_Tick(object sender, EventArgs e)
        {
            time++;
            label1.Text = "Время: "+Convert.ToString(time);
           

        }

        private void новаяИграToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Options options = new Options(this);
            options.Show(); 
        }
    }
}
